﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace ECP.WCFClient
{
    public class ServiceProxyBase<T> : IDisposable
    {

        private ChannelFactory<T> _channelFactory;
        protected T _proxy;

        public ServiceProxyBase(string endpointName)
        {
            _channelFactory = new ChannelFactory<T>(WCFClientConfig.GetBinding(), WCFClientConfig.GetValue(endpointName));
            _proxy = _channelFactory.CreateChannel();

        }


        public void Dispose()
        {
            if (_channelFactory != null)
            {
                try
                {
                    _channelFactory.Close();
                }
                catch
                {
                    _channelFactory.Abort();
                }
            }


        }


    }
}
